﻿// -----------------------------------------------------------------------
// <copyright company="Christoph van der Fecht - VDsoft">
// Copyright (C) Christoph van der Fecht - VDsoft - All Rights Reserved
// Unauthorized copying of this file, via any medium is strictly prohibited,
// unless it is communicated and authorized by the copyright owner.
// </copyright>
// -----------------------------------------------------------------------

using GalaSoft.MvvmLight;

namespace SeriesManager.Model
{
	/// <summary>
	/// An actor of a series.
	/// </summary>
	public class Actor : ObservableObject
	{
		/// <summary>
		/// The image path of the <see cref="Actor"/>.
		/// </summary>
		private string imagePath = null;

		/// <summary>
		/// The name of the <see cref="Actor"/>.
		/// </summary>
		private string name = null;

		/// <summary>
		/// The role the <see cref="Actor"/> plays in the series.
		/// </summary>
		private string role = null;

		/// <summary>
		/// The order the <see cref="Actor"/> is sorted.
		/// </summary>
		private int sortOrder = 0;

		/// <summary>
		/// Initializes a new instance of the <see cref="Actor"/> class.
		/// </summary>
		public Actor()
		{
		}

		/// <summary>
		/// Gets or sets the image path of the <see cref="Actor"/>.
		/// </summary>
		public string ImagePath
		{
			get
			{
				return this.imagePath;
			}

			set
			{
				if (value == this.imagePath)
				{
					return;
				}

				this.imagePath = value;
				this.RaisePropertyChanged();
			}
		}

		/// <summary>
		/// Gets or sets the name of the <see cref="Actor"/>.
		/// </summary>
		public string Name
		{
			get
			{
				return this.name;
			}

			set
			{
				if (value == this.name)
				{
					return;
				}

				this.name = value;
				this.RaisePropertyChanged();
			}
		}

		/// <summary>
		/// Gets or sets the role the <see cref="Actor"/> plays in the series.
		/// </summary>
		public string Role
		{
			get
			{
				return this.role;
			}

			set
			{
				if (value == this.role)
				{
					return;
				}

				this.role = value;
				this.RaisePropertyChanged();
			}
		}

		/// <summary>
		/// Gets or sets the order the <see cref="Actor"/> is sorted.
		/// </summary>
		public int SortOrder
		{
			get
			{
				return this.sortOrder;
			}

			set
			{
				if (value == this.sortOrder)
				{
					return;
				}

				this.sortOrder = value;
				this.RaisePropertyChanged();
			}
		}

		/// <summary>
		/// Converts an <see cref="TVDB.Model.Actor"/> into an <see cref="Actor"/>.
		/// </summary>
		/// <param name="toConvert"><see cref="TVDB.Model.Actor"/> to convert.</param>
		/// <returns><see cref="Actor"/> with all details of the provided object.</returns>
		public static explicit operator Actor(TVDB.Model.Actor toConvert)
		{
			Actor converted = new Actor
			{
				ImagePath = toConvert.ImagePath,
				Name = toConvert.Name,
				Role = toConvert.Role,
				SortOrder = toConvert.SortOrder
			};

			return converted;
		}
	}
}
